\(\int \cot ^2(a+b x) \, dx\) [138]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 8, antiderivative size = 15 \[ \int \cot ^2(a+b x) \, dx=-x-\frac {\cot (a+b x)}{b} \]

[Out]

-x-cot(b*x+a)/b

Rubi [A] (verified)

Time = 0.01 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3554, 8} \[ \int \cot ^2(a+b x) \, dx=-\frac {\cot (a+b x)}{b}-x \]

[In]

Int[Cot[a + b*x]^2,x]

[Out]

-x - Cot[a + b*x]/b

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3554

Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((b*Tan[c + d*x])^(n - 1)/(d*(n - 1))), x] - Dis
t[b^2, Int[(b*Tan[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1]

Rubi steps \begin{align*} \text {integral}& = -\frac {\cot (a+b x)}{b}-\int 1 \, dx \\ & = -x-\frac {\cot (a+b x)}{b} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.01 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.93 \[ \int \cot ^2(a+b x) \, dx=-\frac {\cot (a+b x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(a+b x)\right )}{b} \]

[In]

Integrate[Cot[a + b*x]^2,x]

[Out]

-((Cot[a + b*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[a + b*x]^2])/b)

Maple [A] (verified)

Time = 0.05 (sec) , antiderivative size = 21, normalized size of antiderivative = 1.40

method result size
derivativedivides \(\frac {-\cot \left (b x +a \right )-b x -a}{b}\) \(21\)
default \(\frac {-\cot \left (b x +a \right )-b x -a}{b}\) \(21\)
risch \(-x -\frac {2 i}{b \left ({\mathrm e}^{2 i \left (b x +a \right )}-1\right )}\) \(24\)
parallelrisch \(\frac {-2 b x -\cot \left (\frac {b x}{2}+\frac {a}{2}\right )+\tan \left (\frac {b x}{2}+\frac {a}{2}\right )}{2 b}\) \(31\)
norman \(\frac {-\frac {1}{2 b}+\frac {\tan ^{2}\left (\frac {b x}{2}+\frac {a}{2}\right )}{2 b}-x \tan \left (\frac {b x}{2}+\frac {a}{2}\right )}{\tan \left (\frac {b x}{2}+\frac {a}{2}\right )}\) \(47\)

[In]

int(cos(b*x+a)^2/sin(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

1/b*(-cot(b*x+a)-b*x-a)

Fricas [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.93 \[ \int \cot ^2(a+b x) \, dx=-\frac {b x \sin \left (b x + a\right ) + \cos \left (b x + a\right )}{b \sin \left (b x + a\right )} \]

[In]

integrate(cos(b*x+a)^2/sin(b*x+a)^2,x, algorithm="fricas")

[Out]

-(b*x*sin(b*x + a) + cos(b*x + a))/(b*sin(b*x + a))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 29 vs. \(2 (10) = 20\).

Time = 0.33 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.93 \[ \int \cot ^2(a+b x) \, dx=\begin {cases} - x - \frac {\cos {\left (a + b x \right )}}{b \sin {\left (a + b x \right )}} & \text {for}\: b \neq 0 \\\frac {x \cos ^{2}{\left (a \right )}}{\sin ^{2}{\left (a \right )}} & \text {otherwise} \end {cases} \]

[In]

integrate(cos(b*x+a)**2/sin(b*x+a)**2,x)

[Out]

Piecewise((-x - cos(a + b*x)/(b*sin(a + b*x)), Ne(b, 0)), (x*cos(a)**2/sin(a)**2, True))

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 18, normalized size of antiderivative = 1.20 \[ \int \cot ^2(a+b x) \, dx=-\frac {b x + a + \frac {1}{\tan \left (b x + a\right )}}{b} \]

[In]

integrate(cos(b*x+a)^2/sin(b*x+a)^2,x, algorithm="maxima")

[Out]

-(b*x + a + 1/tan(b*x + a))/b

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 35 vs. \(2 (15) = 30\).

Time = 0.43 (sec) , antiderivative size = 35, normalized size of antiderivative = 2.33 \[ \int \cot ^2(a+b x) \, dx=-\frac {2 \, b x + 2 \, a + \frac {1}{\tan \left (\frac {1}{2} \, b x + \frac {1}{2} \, a\right )} - \tan \left (\frac {1}{2} \, b x + \frac {1}{2} \, a\right )}{2 \, b} \]

[In]

integrate(cos(b*x+a)^2/sin(b*x+a)^2,x, algorithm="giac")

[Out]

-1/2*(2*b*x + 2*a + 1/tan(1/2*b*x + 1/2*a) - tan(1/2*b*x + 1/2*a))/b

Mupad [B] (verification not implemented)

Time = 0.15 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.00 \[ \int \cot ^2(a+b x) \, dx=-x-\frac {\mathrm {cot}\left (a+b\,x\right )}{b} \]

[In]

int(cos(a + b*x)^2/sin(a + b*x)^2,x)

[Out]

- x - cot(a + b*x)/b